<extend name="Public/base"/>
 <block name="style">
    <load  href="__PUBLIC__/static/bootstrap/css/bootstrap.min.css"/>
    <style type="text/css">
    .data-table  a:visited {color: saddlebrown}
    </style>
 </block>
<block name="body">
		<h2 class="heading h2">询单列表</h2> 

	<div class="cf">
		<a class="btn btn-primary" href="{:U('add')}">新 增</a>
        <button class="btn ajax-post confirm btn-primary" target-form="ids" url="{:U('setStatus',array('status'=>-1))}">删 除</button>
		<button class="btn btn-primary" url="{:U('charge?id='.I('id'),'','')}" id="charge_btn">分配询单</button>
		<a class="btn btn-primary" href="{:U('index?charge_man='.is_login(),'','')}" >我的询单</a>
		<a class="btn btn-primary" href="{:U('import','','')}" >导入询单</a>
        
		<!-- 高级搜索 -->
		<div class="search-form fr cf">
			<div class="sleft">
            <form class="search-form pull-right" method='get' action="{:U('Inquiry/index')}">
                负责人:{:get_user_list(I('charge_man'),'span2','charge_man')}
                状态:{:config_list(C('Inquiry_status'),I('request.status'))}
                内容 <input type="text" name="remark" value="{:I('remark')}" placeholder="请输入内容" />
                备注 <input type="text" name="note" value="{:I('note')}" placeholder="请输入备注" />
                <select name="time_type" class="span2"> 
                    <option value="2" <eq name="_REQUEST.time_type" value="2">selected</eq> >创建时间</option> 
                    <option value="1" <eq name="_REQUEST.time_type" value="1">selected</eq> >修改时间</option> 
                </select>
                从<input type="text" class="span2"  name="start_time" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" value="<notempty name='_REQUEST.start_time'>{$_REQUEST.start_time}</notempty>">

                到<input type="text" class="span2" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" name="end_time" id="end_time" value="<notempty name='_REQUEST.end_time'>{$_REQUEST.end_time}</notempty>" >
                单号 <input class="span2" name="mano" type="text" value="{:I('mano')}" />
				标题<input type="text" name="title" value="{:I('title')}" placeholder="请输入询单标题">
                <input type="submit" class="btn btn-primary" value="搜索">
               </form>
			</div>
		</div>
	</div>

	<div class="data-table table-striped">
		<table>
			<thead>
				<tr>
					<th class="row-selected">
						<input class="checkbox check-all" type="checkbox">
					</th>
					<th>询单号</th>
					<th>标题</th>
					<th>创建时间</th>
					<th>修改时间</th>
					<th>状态</th>
					<th>备注</th>
					<th>负责人</th>
					<th>创建人</th>
					<th>最后修改人</th>
				</tr>
			</thead>
			<tbody>
				<notempty name="list">
				<volist name="list" id="config">
					<tr>
						<td><input class="ids row-selected" type="checkbox" name="ids[]" value="{$config.id}"></td>
						<td><a href="{:U('edit?id='.$config['id'])}">{$config.mano}</a></td>
						<td><a href="{:U('edit?id='.$config['id'])}">{$config.title}</a></td>
						<td>{$config.create_time|time_format}</td>
						<td>{$config.update_time|time_format}</td>
						<td><a title="改状态" href="{:U('editStatus?id='.$config['id'])}">{$config.status|get_config_array_value='INQUIRY_STATUS'}</a></td>
						<td><a title="改备注" href="{:U('editNote?id='.$config['id'])}">{$config.note|strip_tags|msubstr=0,60}</a></td>
						<td>{$config.charge_man|get_nickname}</td>
						<td>{$config.creater|get_nickname}</td>
						<td>{$config.user_id|get_nickname}</td>
					</tr>
				</volist>
				<else/>
				<td colspan="6" class="text-center"> aOh! 暂时还没有内容! </td>
				</notempty>
			</tbody>
		</table>
		<!-- 分页 -->
	    <div class="page">
	        {$_page}
	    </div>
	</div>
</block>

<block name="script">
<script type="text/javascript">
$(function(){
	//搜索功能
	$("#search").click(function(){
		var url = $(this).attr('url');
        var query  = $('.search-form').find('input').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        query = query.replace(/^&/g,'');
        if( url.indexOf('?')>0 ){
            url += '&' + query;
        }else{
            url += '?' + query;
        }
		window.location.href = url;
	});
	//回车搜索
	$(".search-input").keyup(function(e){
		if(e.keyCode === 13){
			$("#search").click();
			return false;
		}
	});
	//点击排序
	$('.list_sort').click(function(){
		var url = $(this).attr('url');
		var ids = $('.ids:checked');
		var param = '';
		if(ids.length > 0){
			var str = new Array();
			ids.each(function(){
				str.push($(this).val());
			});
			param = str.join(',');
		}

		if(url != undefined && url != ''){
			window.location.href = url + '/ids/' + param;
		}
	});
	//charge
	$('#charge_btn').click(function(){
		var url = $(this).attr('url');
		var ids = $('.ids:checked');
		var param = '';
		if(ids.length > 0){
			var str = new Array();
			ids.each(function(){
				str.push($(this).val());
			});
			param = str.join(',');
		}

		if(url != undefined && url != ''){
			window.location.href = url + '/ids/' + param;
		}
	});
});
</script>
<load href="__PUBLIC__/static/My97DatePicker/WdatePicker.js" />
</block>
